# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=libheif
pkgver=1.7.0
pkgrel=0
pkgdesc="ISO/IEC 23008-12:2017 HEIF file format decoder and encoder"
url="https://www.libde265.org"
arch="all"
license="LGPL-3.0-or-later"
depends_dev="x265-dev libde265-dev"
makedepends="$depends_dev libjpeg-turbo-dev libpng-dev"
options="!check"  # no tests provided
subpackages="$pkgname-dev $pkgname-tools $pkgname-doc"
source="https://github.com/strukturag/libheif/releases/download/v$pkgver/libheif-$pkgver.tar.gz"

# secfixes:
#   1.5.0-r0:
#     - CVE-2019-11471

build() {
	# This is en/decoder, so performance matters more than size.
	export CPPFLAGS="${CFLAGS/-Os/-O2}"
	export CXXFLAGS="${CFLAGS/-Os/-O2}"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-static
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

tools() {
	pkgdesc="$pkgdesc (tools)"

	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="13c95540fee13f3fba8d8a4f69886bf5563e9fa22c5cd113dbe16d20670b077b5961171e5f9fb0f256cc42c4650e13465c93d3fbb03013997a7fc163463e8b3a  libheif-1.7.0.tar.gz"
